<extend name="./Application/Admin/View/Layout/application.html"/>

<block name="content">

    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑分类</strong> /
                <small>Create A New Category</small>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">

                <form class="am-form" action="__SELF__" method="post">

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            上级分类
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <select data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                    name="parent_id">

                                <eq name="cate.parent_id" value="0">
                                    <option value="0">顶级分类</option>
                                    <else/>
                                    <volist name="categories" id="category">
                                        <option value="{{$category.id}}"
                                        <eq name="category.id" value="$cate.parent_id">selected</eq>
                                        >
                                        {{$category.name}}</option>
                                    </volist>
                                </eq>
                            </select>
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            分类名称
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" minlength="3" required name="name"
                                   value="{{$cate.name}}">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            描述信息
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <textarea rows="4" name="description" required>{{$cate.description}}</textarea>
                        </div>
                    </div>

                    <div class="am-g am-margin-top sort">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            排序
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" name="sort_order" class="am-input-sm" value="{{$cate.sort_order}}">
                        </div>
                    </div>

                    <div class="am-g am-margin-top sort">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            是否显示
                        </div>
                        <div class="am-u-sm-3 am-u-sm-10">
                            <label class="am-radio-inline">
                                <input type="radio" value="1" name="is_show"
                                <eq name="cate.is_show" value="1">checked</eq>> 是
                            </label>
                            <label class="am-radio-inline">
                                <input type="radio" value="0" name="is_show"
                                <eq name="cate.is_show" value="0">checked</eq>> 否
                            </label>
                        </div>
                    </div>

                    <div class="am-margin">
                        <button type="submit" class="am-btn am-btn-primary am-radius">提交保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</block>

<block name="js">
    <script src="__PUBLIC__/vendor/validate/jquery.validate.js"></script>
    <script src="__PUBLIC__/vendor/validate/localization/messages_zh.js"></script>

    <script>
        $(function () {
            $(".am-form").validate({
                onfocusout: function (element) {
                    $(element).valid();
                }
            });
        });
    </script>
</block>